package anli;

import java.util.Arrays;
import java.util.Scanner;

public class anli4 {
    public static void main(String[] args) {
       System.out.println("选手" + score(6) + "大啊");
    }

    public static double score(int number) {
        /**创建一个数组number是随机定义的变量**/
        int[] scores = new int[number];
        Scanner scanner = new Scanner(System.in);
        /**循环选手**/
        for (int i = 0; i < scores.length; i++) {
            //请录入第几个选手 (i+1)下标为0，+1证明从第一个开始算
            System.out.println("请录入" + (i + 1) + "个选手");
            //用scanner方法 输入控制台第几个选手的成绩
            int nextInt = scanner.nextInt();
            //通过第几个选手成绩 赋值给对应的下标位置上
            scores[i] = nextInt;
        }

        int num = 0;
        int max = scores[0];
        int min = scores[0];

        for (int i = 0; i < scores.length; i++) {
            int score = scores[i];
            num += score;
            if (score > max) {
                max = score;

            }
            if (score < min) {
                min = score;
            }


        }
        /**1.0(为了转换小数类型)*(选手成绩总和-最小选手成绩-最大选手成绩）/(选手数量-2 2代表最大成绩和最小成绩)*/
        return 1.0 * (num - min - max) / (number - 2);
    }
}

